package com.qfedu.yuxiaoer.controller;

import com.qfedu.yuxiaoer.common.api.CommonResult;
import com.qfedu.yuxiaoer.dto.SourceresourcesDto;
import com.qfedu.yuxiaoer.service.SourceownerService;
import com.qfedu.yuxiaoer.service.SourceresourcesService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 录入房源
 */
@RestController
@RequestMapping("/sourceresources")
public class sourceresourcesController {

    @Autowired
    private SourceresourcesService sourceresourcesService;
    @Autowired
    private SourceownerService sourceownerService;

    @ApiOperation("录入房源")

    @RequestMapping(value = "/addsourceresources", method = RequestMethod.POST)
    public CommonResult addsourceresources(@RequestBody SourceresourcesDto sourceresourcesDto) {


        int SourceownerId = sourceownerService.insertSourceowner(sourceresourcesDto);
        System.out.println("SourceownerId = " + SourceownerId);
        sourceresourcesDto.setOwnerId(SourceownerId);
        int sourceresources = sourceresourcesService.sourceresources(sourceresourcesDto);




        if(sourceresources>0){
            return CommonResult.success("添加成功");
        }

        return CommonResult.failed("添加失败");



    }
}
